package com.noble.meether.chat.ui.agora.act.dialog;

import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.noble.library.image.ImageLoader;
import com.noble.meether.R;
import com.noble.glamour.bean.my.GiftsList;
import com.noble.glamour.module.logic.application.App;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewAdapter;
import com.noble.library.widget.RecyclerView.base.BaseRecyclerViewHolder;

/**
 * 礼物弹框列表
 * <p>
 * Created by Su on 2017/7/22.
 */
public class GiftPanelAdapter extends BaseRecyclerViewAdapter<GiftsList.GiftInfo> {
    private int selectPosition = 0;

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.f1_gift_panel_dialog_item};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, int position) {
        GiftsList.GiftInfo giftInfo = getItem(position);

        LinearLayout ll_gift = viewHolder.findViewById(R.id.gift_item_ll);
        ImageView iv_gift = viewHolder.findViewById(R.id.gift_item_img);
        TextView tv_cost = viewHolder.findViewById(R.id.gift_item_cost);
        TextView tv_name = viewHolder.findViewById(R.id.gift_item_name);

        ImageLoader.loadCenterCrop(App.context, giftInfo.getPic(), iv_gift, R.drawable.default_gift, R.drawable.default_gift);
        tv_cost.setText(App.activity.getString(R.string.goods_diamond_need, giftInfo.getMoney()));
        tv_name.setText(giftInfo.getName());

        // 选中状态
        ll_gift.setSelected(selectPosition == position);
    }

    public void updateData(int positon) {
        this.selectPosition = positon;
        notifyDataSetChanged();
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }
}
